package fr.anime.model.explorer;


import java.io.File;
import java.util.ArrayList;

public class Drives {
	private static Drives singleton;
	private ArrayList<Drive> drives;
	
	private Drives() {
		drives = new ArrayList<Drive>();
		File[] drives = File.listRoots();
		for (File file : drives) {
			Drive drive = new Drive(file);
			this.drives.add(drive);
			
		}
	}
	
	



	public static Drives getInstance() {
		if (singleton==null) {
			singleton = new Drives();
		}
		return singleton;
	}
	
	
	public ArrayList<Drive> getDrives() {
		return this.drives;
	}
	
	public String[] getFiles(String driveName) {
		for (Drive drive : drives) {
			if (drive.getName().equals(driveName)) {
				return drive.getFile().list();
			}
		}
		return null;
	}	
	public Drive getDrive(String driveName) {
		for (Drive drive : drives) {
			if (drive.getName().equals(driveName)) {
				return drive;
			}
		}
		return null;
	}
	
	
}

